<?php if ( $_SESSION['logged_in'] == FALSE ) redirect (base_url ()); ?>
    <script language="javascript" type="text/javascript">
        function getpass() {
            var pass = '<?php echo rand_passwd(); ?>' ;
            alert(pass);
            document.getElementById("uc").innerHTML = pass;
            
        }
    </script>    

    <div onclick="getpass()" style="background-color:yellow; color:blue; cursor:pointer;">
        Generate
    </div>
    <div id="uc" style="background-color:grey; color:blue;">Pass</div>
    <div id="en"></div>
    
    

    
<?php

function rand_passwd( $length = 8, $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ) {
            return substr( str_shuffle( $chars ), 0, $length );
        }

?>